<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>layui</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<link rel="stylesheet" href="__PUBLIC__/layui/css/layui.css"  media="all">
	<script src="__PUBLIC__/layui/layui.js" charset="utf-8"></script>
	<script src="__PUBLIC__/js/jquery-1.11.3.js" charset="utf-8"></script>
</head>
<body style="background-color: #fff;">

	<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;text-align: center;font-family: kaiti;">
		<legend>添加班级信息</legend>
	</fieldset>

	<div style="width: 500px; margin: 15px auto;padding: 15px;border: 2px solid #666;background-color: #fff;">
		<form class="layui-form" action="__CONTROLLER__/add" method="post">

		<div class="layui-form-item" style="width: 400px;">
			<label class="layui-form-label" >班级名称</label>
			<div class="layui-input-block">
				<input type="text" name="class_name" id="c_name" class="layui-input required" placeholder="必填" autocomplete="off">
			</div>
		</div>

		<div class="layui-form-item" style="width: 400px;">
			<label class="layui-form-label" >学生人数</label>
			<div class="layui-input-block">
				<input type="text" name="student_number" id="s_num" class="layui-input required" placeholder="必填" autocomplete="off">
			</div>
		</div>

		<div class="layui-form-item"  style="width: 400px;">
			<label class="layui-form-label">专业</label>
				<select name="major" id="major" lay-filter="aihao">
					<option value=""></option>
					<foreach name="major_info" item="major">
						<option value="{$major.major_id}">{$major.major_name}</option>
					</foreach>
				</select>
		</div>

		<div class="layui-form-item"  style="width: 400px;">
			<label class="layui-form-label">所属学院</label>
				<select name="college" id="college" lay-filter="aihao">
					<option value=""></option>
					<foreach name="college_info" item="college">
						<option value="{$college.college_id}">{$college.college_name}</option>
					</foreach>
				</select>
		</div>

		<div class="layui-form-item layui-form-text">
			<label class="layui-form-label ">备注</label>
			<div class="layui-input-block">
				<textarea name="note" placeholder="添加备注" class="layui-textarea"></textarea>
			</div>
		</div>

		<div class="layui-form-item">
			<div class="layui-input-block">
				<input type="submit" value="确定" id="sure" class="layui-btn">
				<button type="reset" class="layui-btn layui-btn-primary">重置</button>
				<a href="http://www.sinon.com/index.php/Admin/class/index" class="layui-btn">取消</a>
			</div>
		</div>
	</form>
	</div>
</body>
</html>

<script>
	layui.use(['form', 'layedit', 'laydate'], function(){
		var form = layui.form
		,layer = layui.layer
		,layedit = layui.layedit
		,laydate = layui.laydate;

	    //日期
	    laydate.render({
	    	elem: '#date'
	    });
	    laydate.render({
	    	elem: '#date1'
	    });
	    
	    //创建一个编辑器
	    var editIndex = layedit.build('LAY_demo_editor');  
	});

	$('#sure').on('click', function(){
		var cna = $('#c_name').val();
		var num = $('#s_num').val();
		var major = $('#major').val();
		var col = $('#college').val();

		if(cna==''||major==''||num==''||col==''){
			layer.msg('请填写完整数据');
			return false;
		}

		if(isNaN(num)){
			layer.msg('学生人数是数字哦！');
			return false;
		}

		if(num==0){
            layer.msg('学生人数不能为0！');
            return false;
        }

        if(num<0){
            layer.msg('学生人数不能为负数！');
            return false;
        }

		
	}); 

	$(document).ready(function(){
        $('input').attr('autocomplete', 'off'); 
    })



</script>

<style>
	.layui-form-select .layui-edge {
		position: absolute;
		right: 60px;
		top: 50%;
		margin-top: -3px;
		cursor: pointer;
		border-width: 6px;
		border-top-color: #c2c2c2;
		border-top-style: solid;
		transition: all .3s;
		-webkit-transition: all .3s;
	}
	.layui-input, .layui-textarea {
		display: block;
		width: 250px;
		padding-left: 10px;
	}
	.layui-form-select dl dd, .layui-form-select dl dt {
		padding: 6px 21px;
		line-height: 35px;
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
	}
	.layui-form-select dl {
		left: 100px;
		min-width: 62%;
	}
</style>

</body>
</html>